<!DOCTYPE html>
<html>
#{include file="header.html"}#
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5><i class="fa fa-home"></i> 员工列表</h5>
                    <div class="ibox-tools"><a href="javascript:void(0);" class="btn btn-xs btn-default btn-help-detail" data-type="hrm_staff"> <i class="fa fa-question-circle"> 操作说明</i></a>
                    </div>
                </div>
                <div class="ibox-content table-responsive">
                    <div class="row">
                        <form id="pagerForm" method="post" class="form-inline">
                            <div class="col-sm-3 m-b-xs">
                                <a href="?" class="btn  btn-default"> <i class="fa fa-refresh"> 刷新</i></a>
                                <a href="javascript:void(0)" class="btn btn-info ajax-open" data-url="#{$smarty.const.ACT}#/hrm/HrmStaff/hrm_staff_add/" data-title="添加"><i class="fa fa-plus"></i> 添加</a>
                            </div>
                            <div class="col-sm-9 m-b-xs text-right">

                                <div class="input-group pd-b-5">
                                    <input type="text" name="keywords" placeholder="请输入员工关键词" class="form-control">
                                </div>
                                <div class="input-group"> <span class="input-group-btn">
                  <button type="button" class="btn btn-primary ajaxSearchForm"><i class="fa fa-search"></i> 搜索</button>
                  </span></div>
                            </div>
                        </form>
                    </div>
                    <table class="table table-hover sorttable 07fly-table" width="100%">
                        <thead>
                        <tr>
                            <th width="22"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
                            <th width="80"><span>员工编号</span></th>
                            <th width="80"><span>姓名</span></th>
                            <th width="100"><span>性别</span></th>
                            <th width="100"><span>年龄</span></th>
                            <th width="100"><span>婚姻情况</span></th>
                            <th width="100"><span>政治面貌</span></th>
                            <th width="100"><span>最高学历</span></th>
                            <th width="100"><span>就读专业</span></th>
                            <th width="100"><span>职业资格</span></th>
                            <th width="100"><span>工作职务</span></th>
                            <th width="100"><span>社会职务</span></th>
                            <th width="100"><span>手机号码</span></th>
                            <th width="100"><span>联系地址</span></th>
                            <th width="80">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                    <table class="table 07fly-table">
                        <tfoot class="ibox-content">
                        <tr>
                            <td align="center" class="pagestring"></td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script id="tableListTpl" type="text/html">
    <% for(var i=0;i <list.length;i++) { %>
    <tr>
        <td><input name="id" class="checkboxCtrlId" value="<%=list[i]['id']%>" type="checkbox" ></td>
        <td><a href="#{$smarty.const.ACT}#/hrm/HrmStaff/hrm_staff_detail/id/<%=list[i]['id']%>/"><%=list[i]['staff_no']%></a>
        </td>
        <td><%=list[i]['name']%></td>
        <td><% if(list[i]['gender']==1){%>男<%}else{%>女<%}%>		</td>
        <td><%=list[i]['age']%></td>
        <td><%=list[i]['marriage']%></td>
        <td><%=list[i]['politics']%></td>
        <td><%=list[i]['degree']%></td>
        <td><%=list[i]['major']%></td>
        <td><%=list[i]['qualification']%></td>
        <td><%=list[i]['position']%></td>
        <td><%=list[i]['social']%></td>
        <td><%=list[i]['mobile']%></td>
        <td><%=list[i]['address']%></td>

        <td width='10'>
            <a href="javascript:void(0)"  class="ajax-open" data-url="#{$smarty.const.ACT}#/hrm/HrmStaff/hrm_staff_modify/"  data-id="<%=list[i]['id']%>" data-title="修改">修改</a>
            <a href="javascript:void(0)"  class="ajax-get" data-url="#{$smarty.const.ACT}#/hrm/HrmStaff/hrm_staff_del/"  data-id="<%=list[i]['id']%>" data-title="删除">删除</a>

        </td>
    </tr>
    <% } %>
</script>
<script src="#{$smarty.const.APP}#/View/template/js/content.js?v=1.0.0"></script>
<script type="text/javascript">
    var ajaxUrl = '#{$smarty.const.ACT}#/hrm/HrmStaff/hrm_staff_json/';

    $(document).ready(function () {

        turnPage(1);//页面加载时初始化分页
        $('.chosen-select').chosen({search_contains: true});
        $('.chosen-select').chosen().change(function () {
            ajaxSearchFormData = $("form").serialize();
            turnPage(1);
        });

        //批量操作
        $("body").on("click", ".batch_operation", function () {
            batch_act = $(this).attr("data-act")
            var chk_value = [];
            $("tbody input[class='checkboxCtrlId']:checked").each(function () {
                chk_value.push($(this).val());
            });
            id_txt = chk_value.join(",");
            if (batch_act == "del") {
                act_url = "#{$smarty.const.ACT}#/crm/CstCustomer/cst_customer_del/";
                layer.confirm('确定删除吗？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    $.ajax({
                        type: "POST",
                        url: act_url,
                        data: {"id": id_txt},
                        dataType: "json",
                        async: false,
                        success: function (data) {
                            if (data.statusCode == '200') {
                                layer.msg('操作成功', {icon: 1});
                                setTimeout(function () {
                                    turnPage(1);
                                }, 800);
                            }
                        }
                    });
                    layer.closeAll('dialog');
                });
                return false;
            }
        });

        //单击操作
        $("body").on("click", ".ajax-open", function () {
            var target = $(this).attr("data-url");
            var id = $(this).attr("data-id");
            if (typeof (id) != "undefined" && id != 0) {
                var target = target + "?id=" + id;
            }
            var title = $(this).attr("data-title");
            log(target);
            layer.open({
                type: 2,
                title: title,
                shadeClose: true,
                fixed: false, //不固定
                area: ['90%', '90%'],
                content: target,
                end: function () {
                    turnPage(1);//页面加载时初始化分页
                }
            });
            return false;
        });

        //单击操作
        $("body").on("click", ".ajax-get", function () {
            var target = $(this).attr("data-url");
            var id = $(this).attr("data-id");
            if (typeof (id) != "undefined" && id != 0) {
                var target = target + "?id=" + id;
            }
            $.ajax({
                type: "POST",
                url: target,
                data:{"id":id},
                dataType:"json",
                success: function(data){
                    if(data.statusCode=='200'){
                        layer.msg('操作成功', {icon: 1});
                        turnPage(1);
                    }
                },
                complete: function () {//完成响应
                }
            });
        });

    });
</script>